﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows;
using System.Windows.Media;

namespace LEDShow.Models
{
    class NamePlateModel : INotifyPropertyChanged
    {
        #region 公共属性
        private string _position;
        public string Position
        {
            get { return _position; }
            set
            {
                if (value == _position)
                    return;
                if (value == "电客车司机长")
                    _position = "司机长";
                else
                    _position = value;

                InitByPosition();

                OnPropertyChanged("Position");
            }
        }

        private string _jobNum;
        public string JobNum
        {
            get { return _jobNum; }
            set
            {
                if (_jobNum == value)
                    return;

                _jobNum = value;

                OnPropertyChanged("JobNum");
            }
        }


        private string _userName;
        public string UserName
        {
            get { return _userName; }
            set
            {
                if (value == _userName)
                    return;

                _userName = value;

                OnPropertyChanged("UserName");
            }
        }

        public string RunTrainString { get; set; }

        /// <summary>
        /// 开始接车时间
        /// </summary>
        public string BeginTrainTime { get; set; }

        /// <summary>
        /// 退勤时间
        /// </summary>
        public string OffTime { get; set; }

        private string _trainID;
        public string TrainID
        {
            get { return _trainID; }
            set
            {
                if (value == _trainID)
                    return;

                _trainID = value;

                OnPropertyChanged("TrainID");
            }
        }

        private Visibility _trainID_visibity = Visibility.Visible;
        public Visibility TrainIDVisibity
        {
            get { return _trainID_visibity; }
            set
            {
                if (_trainID_visibity == value)
                    return;

                _trainID_visibity = value;

                OnPropertyChanged("TrainIDVisibity");
            }
        }

        private Brush _backGround = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F2F2F8"));
        public Brush BackGround
        {
            get { return _backGround; }
            set
            {
                if (_backGround == value)
                    return;

                _backGround = value;
                OnPropertyChanged("BackGround");
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        public virtual void OnPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = this.PropertyChanged;
            if (null != handler)
            {
                var e = new PropertyChangedEventArgs(propertyName);
                handler(this, e);
            }
        }

        /// <summary>
        /// 计划出勤时间
        /// </summary>
        public DateTime? planAtten { set; get; }

        /// <summary>
        /// 显示出来的计划退勤时间
        /// </summary>
        public string showPlanAtten { set; get; }

        /// <summary>
        /// 计划退勤时间
        /// </summary>
        public DateTime? planOutOffTime { set; get; }

        /// <summary>
        /// 显示出来的退勤时间
        /// </summary>
        public string showPlanOutOffTime { set; get; }

        /// <summary>
        /// 实际退勤时间
        /// </summary>
        public DateTime? actualOutOffTime { set; get; }

        /// <summary>
        /// 实际出勤时间
        /// </summary>
        public DateTime? actualAtten { set; get; }

        /// <summary>
        /// 显示出勤状态
        /// </summary>
        public string status { set; get; }


        #endregion

        /// <summary>
        /// 司机长深黄色
        /// </summary>
        private SolidColorBrush _teamLeaderBackground = Brushes.Azure;

        /// <summary>
        /// 排班员蓝色
        /// </summary>
        //private SolidColorBrush _pbyBackground = Brushes.AntiqueWhite;
        private SolidColorBrush _pbyBackground = Brushes.Azure;

        ///<summary>
        ///车场调度员颜色
        ///</summary>
        private SolidColorBrush _ccduyBackground = Brushes.Azure;

        /// <summary>
        /// 迟到员工的颜色
        /// </summary>
        private SolidColorBrush _lateBackgroud = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F7D6D6"));

        /// <summary>
        /// 早退颜色
        /// </summary>
        private SolidColorBrush _leaveEarlierBackGround = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#C2BEBE"));


        private void InitByPosition()
        {
            if (_position != "电客车司机" && _position != "实习生")
            {
                this.TrainIDVisibity = Visibility.Collapsed;
                if (_position == "司机长")
                    this.BackGround = _teamLeaderBackground;
                else if (_position == "派班员" || _position == "督导员")
                    this.BackGround = _pbyBackground;
                else if (_position == " 车场调度员")
                    this.BackGround = _ccduyBackground;
            }
        }

        /// <summary>
        /// 设置迟到司机()
        /// </summary>
        public void SetLateDriver()
        {
            this.BackGround = _lateBackgroud;
            this.status = "迟到";
        }

        /// <summary>
        /// 设置早退司机
        /// </summary>
        public void SetLeaveEarlierBackGround()
        {
            this.BackGround = _leaveEarlierBackGround;
            this.status = "早退";
        }

        /// <summary>
        /// 设置晚退司机颜色
        /// </summary>
        public void SetOffLateBackGround()
        {
            this.BackGround = _leaveEarlierBackGround;
            this.status = "未退";
        }

    }
}
